<template>
  <div class="wing-nickname-generator">
    <div class="container">
      <h1>翅膀昵称生成器</h1>
      <el-input v-model="nickname" placeholder="请输入名字" :modelValue="'名字'"></el-input>
      <el-select v-model="selectedWing" placeholder="选择翅膀样式" class="wing-select">
        <el-option
          v-for="wing in wings"
          :key="wing"
          :label="wing"
          :value="wing">
        </el-option>
      </el-select>
      <div class="result" v-if="result">{{ result }}</div>
      <div class="button-group">
        <el-button type="primary" @click="generateNickname">
          <el-icon><Pointer /></el-icon>
          生成
        </el-button>
        <el-button type="success" @click="copyResult" :disabled="!result">
          <el-icon><DocumentCopy /></el-icon>
          复制
        </el-button>
        <el-button type="warning" @click="goToHomepage">
          <el-icon><Back /></el-icon>
          返回首页
        </el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { Pointer, DocumentCopy, Back } from '@element-plus/icons-vue'
import { copyText } from '@/utils/clipboard'

const router = useRouter()
const nickname = ref('名字') // 设置默认值为"名字"
const result = ref('')

const wings = [
  '꧁翅膀꧂', '꧁༺翅膀༻꧂', '꧁༺๑翅膀๑༻꧂', '༺ཌༀൢ翅膀ൢༀད༻', '꧁༺△翅膀△༻꧂',
  '꧁❦༺翅膀༻❦꧂', '꧁༺༽༾ཊ翅膀ཏ༿༼༻꧂', '꧁༺❀ൢ翅膀ൢ❀༻꧂', '꧁❀翅膀❀꧂', 'ༀ꧁꫞翅膀꫞꧂ༀ',
  '࿐ཉི༗࿆翅膀༗࿆ཉི࿐', '༺༃翅膀༃༻', '༺།༼࿄࿆翅膀࿅࿆༽།༻', '༺翅膀༻', '༺༒翅膀༒༻',
  '༺ཌༀཉི翅膀༃ༀད༻', '༺ཉི།翅膀།ཉྀ༻', '༺❀ൢ翅膀ൢ❀༻', '༺༃★翅膀★༃༻', '༺࿈翅膀࿈༻',
  '༺༽༾ཊ翅膀ཏ༿༼༻', '༺ཌ༈翅膀༈ད༻', '༄༊翅膀ོྂཾ࿆࿐', '༺ཌༀ翅膀ༀད༻', '༺❦翅膀❦༻',
  '︶﹌⋛翅膀⋚﹌︶'
]

const selectedWing = ref(wings[0])

const generateNickname = () => {
  if (!nickname.value || !selectedWing.value) {
    ElMessage.warning('请输入昵称并选择翅膀样式')
    return
  }
  result.value = selectedWing.value.replace('翅膀', nickname.value)
}

const copyResult = () => {
  if (result.value) {
    copyText(result.value)
  }
}

const goToHomepage = () => {
  router.push('/')
}
</script>

<style lang="scss" scoped>
.wing-nickname-generator {
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  margin: 0;
  padding: 40px 20px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;

  .container {
    max-width: 600px;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    padding: 40px;
    box-sizing: border-box;

    h1 {
      text-align: center;
      color: #4a5568;
      font-size: 2.5em;
      margin-bottom: 30px;
      text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    }

    .el-input {
      margin-bottom: 20px;
    }

    .wing-select {
      width: 100%;
      margin-bottom: 20px;
    }

    .result {
      font-size: 24px;
      text-align: center;
      margin: 20px 0;
      padding: 20px;
      background-color: #f0f5ff;
      border-radius: 12px;
      box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
      transition: all 0.3s ease;

      &:hover {
        transform: scale(1.02);
        box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
      }
    }

    .button-group {
      display: flex;
      justify-content: space-between;
      gap: 15px;
      margin-top: 30px;

      .el-button {
        flex: 1;
        height: 44px;
        font-size: 16px;
        border-radius: 8px;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;

        .el-icon {
          margin-right: 5px;
        }

        &:hover {
          transform: translateY(-2px);
          box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }
      }
    }
  }
}

@media (max-width: 480px) {
  .wing-nickname-generator {
    padding: 20px;

    .container {
      padding: 20px;

      h1 {
        font-size: 24px;
      }

      .result {
        font-size: 20px;
      }

      .button-group {
        flex-direction: column;

        .el-button {
          margin: 5px 0;
        }
      }
    }
  }
}
</style>
